package com.peter.proxy.hkgolden.api;

import java.util.Collection;
import java.util.Date;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonDeserialize;

import com.peter.framework.data.DataBase;

@SuppressWarnings("serial")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Topic extends DataBase implements Comparable<Topic> {

	@JsonProperty(value = "Message_ID")
	private Integer messageId;
	@JsonProperty(value = "Message_Title")
	private String messageTitle;
	@JsonProperty(value = "Author_ID")
	private Integer authorId;
	@JsonProperty(value = "Author_Gender")
	private String authorGender;
	@JsonProperty(value = "Author_Name")
	private String authorName;
	@JsonProperty(value = "Last_Reply_Date")
	@JsonDeserialize(using = DateDeserializer.class)
	private Date lastReplyDate;
	@JsonProperty(value = "Message_Status")
	private String messageStatus;
	@JsonProperty(value = "Message_Date")
	@JsonDeserialize(using = DateDeserializer.class)
	private Date messageDate;
	@JsonProperty(value = "Message_Body")
	private String messageBody;
	@JsonProperty(value = "Total_Replies")
	private Integer replies;
	@JsonProperty(value = "Rating")
	private Integer rating;
	@JsonProperty(value = "messages")
	private Collection<Message> messages;

	public Integer getMessageId() {
		return messageId;
	}

	public void setMessageId(Integer messageId) {
		this.messageId = messageId;
	}

	public String getMessageTitle() {
		return messageTitle;
	}

	public void setMessageTitle(String messageTitle) {
		this.messageTitle = messageTitle;
	}

	public Integer getAuthorId() {
		return authorId;
	}

	public void setAuthorId(Integer authorId) {
		this.authorId = authorId;
	}

	public String getAuthorGender() {
		return authorGender;
	}

	public void setAuthorGender(String authorGender) {
		this.authorGender = authorGender;
	}

	public String getAuthorName() {
		return authorName;
	}

	public void setAuthorName(String authorName) {
		this.authorName = authorName;
	}

	public Date getLastReplyDate() {
		return lastReplyDate;
	}

	public void setLastReplyDate(Date lastReplyDate) {
		this.lastReplyDate = lastReplyDate;
	}

	public String getMessageStatus() {
		return messageStatus;
	}

	public void setMessageStatus(String messageStatus) {
		this.messageStatus = messageStatus;
	}

	public Date getMessageDate() {
		return messageDate;
	}

	public void setMessageDate(Date messageDate) {
		this.messageDate = messageDate;
	}

	public String getMessageBody() {
		return messageBody;
	}

	public void setMessageBody(String messageBody) {
		this.messageBody = messageBody;
	}

	public Integer getReplies() {
		return replies;
	}

	public void setReplies(Integer replies) {
		this.replies = replies;
	}

	public Integer getRating() {
		return rating;
	}

	public void setRating(Integer rating) {
		this.rating = rating;
	}

	public Collection<Message> getMessages() {
		return messages;
	}

	public void setMessages(Collection<Message> messages) {
		this.messages = messages;
	}

	@Override
	public int compareTo(Topic o) {
		final Integer ida = this.rating;
		final Integer id1a = o.rating;
		final Date idb = this.lastReplyDate;
		final Date id1b = o.lastReplyDate;
		return new CompareToBuilder().append(id1a, ida).append(id1b, idb)
				.toComparison();
	}

}
